
package kaizen.nomweb;

import java.io.*;

import java.util.Properties;
import java.util.Vector;

import javax.servlet.*;
import javax.servlet.http.*;

import kaizen.jdbc.DbAppUnivC;
import kaizen.jdbc.dbRecord;

// Referenced classes of package kaizen.nomweb:
//            ejecuta, templates, utilerias

public class pagolinea extends HttpServlet 
{

  public pagolinea()
  {
  }

  public static String Genera_JavaScript()
  {
    String s = "<SCRIPT LANGUAGE=\"JavaScript\">\n";
    s = s + "<!-- Begin\n";
    s = s + "\n";
    s = s + "function formatCurrency(num)\n";
    s = s + "{\n";
    s = s + "   num = num.toString().replace(/\\$|\\,/g,'');\n";
    s = s + "   if(isNaN(num))\n";
    s = s + "      num = \"0\";\n";
    s = s + "   sign = (num == (num = Math.abs(num)));\n";
    s = s + "   num = Math.floor(num*100+0.50000000001);\n";
    s = s + "   cents = num%100;\n";
    s = s + "   num = Math.floor(num/100).toString();\n";
    s = s + "   if(cents<10)\n";
    s = s + "      cents = \"0\" + cents;\n";
    s = s + "   for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)\n";
    s = s + "      num = num.substring(0,num.length-(4*i+3))+','+\n";
    s = s + "   num.substring(num.length-(4*i+3));\n";
    s = s + "   return (((sign)?'':'-') + num + '.' + cents);\n";
    s = s + "}\n";
    s = s + "\n";
    s = s + "function actualiza_saldo(j)\n";
    s = s + "{\n";
    s = s + "   var test = document.frm.pago[j];\n";
    s = s + "   if (test.checked == true)\n";
    s = s + "   {\n";
    s = s + "      var totalPago = eval(\"document.frm.totPago\" + j);\n";
    s = s + "\t  var saldo = eval(\"document.frm.saldo\" + j);\n";
    s = s + "\t  totalPago.disabled = false;\n";
    s = s + "      totalPago.value = formatCurrency(saldo.value);\n";
    s = s + "      var subtotal = 0;\n";
    s = s + "      for (i = 0; i < document.frm.pago.length; i++)\n";
    s = s + "      {\n";
    s = s + "         totalPago = eval(\"document.frm.totPago\" + i);\n";
    s = 
        s + "\t\t var valor = parseFloat(totalPago.value.toString().replace(/\\$|\\,/g,''))\n";
    s = s + "         subtotal = subtotal + valor;\n";
    s = s + "      }\n";
    s = s + "\n";
    s = s + "      document.frm.txtSub.value = formatCurrency(subtotal);\n";
    s = s + "\n";
    s = 
        s + "      var total = subtotal + parseFloat(document.frm.txtAnti.value.toString().replace(/\\$|\\,/g,''));\n";
    s = s + "      if (total == 0)\n";
    s = s + "         document.frm.txtTot.value = \"0.00\";\n";
    s = s + "      else\n";
    s = s + "         document.frm.txtTot.value = formatCurrency(total);\n";
    s = s + "   }\n";
    s = s + "   else\n";
    s = s + "   {\n";
    s = s + "      var totalPago = eval(\"document.frm.totPago\" + j);\n";
    s = s + "\t     totalPago.disabled = true;\n";
    s = s + "      totalPago.value = \"0.00\";\n";
    s = s + "      var subtotal = 0;\n";
    s = s + "      for (i = 0; i < document.frm.pago.length; i++)\n";
    s = s + "      {\n";
    s = s + "         totalPago = eval(\"document.frm.totPago\" + i);\n";
    s = 
        s + "         var valor = parseFloat(totalPago.value.toString().replace(/\\$|\\,/g,''))\n";
    s = s + "         subtotal = subtotal + valor;\n";
    s = s + "      }\n";
    s = s + "      if (subtotal == 0)\n";
    s = s + "         document.frm.txtSub.value = \"0.00\";\n";
    s = s + "      else\n";
    s = s + "         document.frm.txtSub.value = formatCurrency(subtotal);\n";
    s = s + "\n";
    s = 
        s + "      var total = subtotal + parseFloat(document.frm.txtAnti.value.toString().replace(/\\$|\\,/g,''));\n";
    s = s + "      if (total == 0)\n";
    s = s + "         document.frm.txtTot.value = \"0.00\";\n";
    s = s + "      else\n";
    s = s + "         document.frm.txtTot.value = formatCurrency(total);\n";
    s = s + "   }\n";
    s = s + "}\n";
    s = s + "\n";
    s = s + "function total(i)\n";
    s = s + "{\n";
    s = s + "   var totalPago = eval(\"document.frm.totPago\" + i);\n";
    s = s + "   var totalSaldo = eval(\"document.frm.saldo\" + i);\n";
    s = 
        s + "   if(parseFloat(totalPago.value.toString().replace(/\\$|\\,/g,'')) > parseFloat(totalSaldo.value.toString().replace(/\\$|\\,/g,'')))\n";
    s = s + "   {\n";
    s = 
        s + "      alert('El valor ingresado es mayor al saldo de la factura.');\n";
    s = s + "      totalPago.focus();\n";
    s = s + "   }\n";
    s = s + "   else\n";
    s = s + "   {\n";
    s = 
        s + "      if(parseFloat(totalPago.value.toString().replace(/\\$|\\,/g,'')) >= 0)\n";
    s = s + "      {\n";
    s = s + "         var subtotal = 0;\n";
    s = s + "         totalPago.value = formatCurrency(totalPago.value);\n";
    s = s + "\n";
    s = s + "         for (i = 0; i < document.frm.pago.length; i++)\n";
    s = s + "         {\n";
    s = s + "            totalPago = eval(\"document.frm.totPago\" + i);\n";
    s = 
        s + "            var valor = parseFloat(totalPago.value.toString().replace(/\\$|\\,/g,''))\n";
    s = s + "            subtotal = subtotal + valor;\n";
    s = s + "         }\n";
    s = s + "         if (subtotal == 0)\n";
    s = s + "            document.frm.txtSub.value = \"0.00\";\n";
    s = s + "         else\n";
    s = 
        s + "            document.frm.txtSub.value = formatCurrency(subtotal);\n";
    s = 
        s + "         var total = subtotal + parseFloat(document.frm.txtAnti.value.toString().replace(/\\$|\\,/g,''));\n";
    s = s + "         if (total == 0)\n";
    s = s + "            document.frm.txtTot.value = \"0.00\";\n";
    s = s + "         else\n";
    s = s + "            document.frm.txtTot.value = formatCurrency(total);\n";
    s = s + "      }\n";
    s = s + "      else\n";
    s = s + "      {\n";
    s = s + "         alert('El importe ingresado es menor a 0.');\n";
    s = s + "         totalPago.value = formatCurrency(totalPago+i.value);\n";
    s = s + "         totalPago.focus();\n";
    s = s + "      }\n";
    s = s + "   }\n";
    s = s + "}\n";
    s = s + "\n";
    s = s + "function totalgen()\n";
    s = s + "{\n";
    s = 
        s + "   if (parseFloat(document.frm.txtAnti.value.toString().replace(/\\$|\\,/g,'')) >= 0)\n";
    s = s + "   {\n";
    s = 
        s + "      var total_gen = parseFloat(document.frm.txtSub.value.toString().replace(/\\$|\\,/g,'')) + parseFloat(document.frm.txtAnti.value.toString().replace(/\\$|\\,/g,''));\n";
    s = s + "      document.frm.txtTot.value = formatCurrency(total_gen);\n";
    s = 
        s + "      document.frm.txtAnti.value = formatCurrency(document.frm.txtAnti.value);\n";
    s = s + "   }\n";
    s = s + "   else\n";
    s = s + "   {\n";
    s = s + "      alert('El importe ingresado es menor a 0.');\n";
    s = 
        s + "      document.frm.txtAnti.value = formatCurrency(document.frm.txtAnti.value);\n";
    s = s + "      document.frm.txtAnti.focus();\n";
    s = s + "   }\n";
    s = s + "}\n";
    s = s + "\n";
    s = s + "function valida()\n";
    s = s + "{\n";
    s = 
        s + "   if(parseFloat(document.frm.txtTot.value.toString().replace(/\\$|\\,/g,'')) <= 0)\n";
    s = s + "   {\n";
    s = s + "      alert('El pago Total debe de ser mayor a 0');\n";
    s = s + "      return false;\n";
    s = s + "   }\n";
    s = s + "   else\n";
    s = s + "   {\n";
    s = s + "      if(GetCookie(\"namepago\") == null)\n";
    s = s + "      {\n";
    s = 
        s + "         document.write(\"<table width=\\\"100%\\\" height=\\\"100%\\\" border=\\\"0\\\" background=\\\"/scm/media/fondop.jpg\\\">\");\n";
    s = s + "         document.write(\"  <tr>\");\n";
    s = 
        s + "         document.write(\"    <td><div align=\\\"center\\\">Su transacci\363n a expirado.<br><a href=\\\"/servlet/servlet/ConectAc?dic_estado=92&dic_menu=m01\\\">Para regresar a <img src=\\\"/scm/media/integra/interior_01.jpg\\\" alt=\\\"enlace@montezuma\\\" width=\\\"187\\\" height=\\\"41\\\" align=\\\"middle\\\"> dar click en la imagen.<a><br></div></td>\");\n";
    s = s + "         document.write(\"  </tr>\");\n";
    s = s + "         document.write(\"</table>\");\n";
    s = s + "\t        return false;\n";
    s = s + "      }\n";
    s = s + "\t     else\n";
    s = s + "\t     {\n";
    s = s + "         document.frm.edo_pago.value = \"1\";\n";
    s = s + "         document.frm.Submit.disabled = true;\n";
    s = s + "         createCookie(\"namepago\",\"\",-1);\n";
    s = s + "         return true;\n";
    s = s + "      }\n";
    s = s + "   }\n";
    s = s + "}\n";
    s = s + "\n";
    s = s + "function createCookie(name,value,days)\n";
    s = s + "{\n";
    s = s + "   if (days)\n";
    s = s + "   {\n";
    s = s + "      var date = new Date();\n";
    s = s + "      date.setTime(date.getTime()+(days*24*60*60*1000));\n";
    s = s + "      var expires = \"; expires=\"+date.toGMTString();\n";
    s = s + "   }\n";
    s = s + "   else var expires = \"\";\n";
    s = s + "   document.cookie = name+\"=\"+value+expires+\";\";\n";
    s = s + "}\n";
    s = s + "\n";
    s = s + "function getCookieVal (offset)\n";
    s = s + "{\n";
    s = s + "   var endstr = document.cookie.indexOf (\";\", offset);\n";
    s = s + "   if (endstr == -1)\n";
    s = s + "      endstr = document.cookie.length;\n";
    s = s + "   return unescape(document.cookie.substring(offset, endstr));\n";
    s = s + "}\n";
    s = s + "\n";
    s = s + "function GetCookie (name)\n";
    s = s + "{\n";
    s = s + "   var arg = name + \"=\";\n";
    s = s + "   var alen = arg.length;\n";
    s = s + "   var clen = document.cookie.length;\n";
    s = s + "   var i = 0;\n";
    s = s + "   while (i < clen)\n";
    s = s + "   {\n";
    s = s + "      var j = i + alen;\n";
    s = s + "      if (document.cookie.substring(i, j) == arg)\n";
    s = s + "         return getCookieVal (j);\n";
    s = s + "      i = document.cookie.indexOf(\" \", i) + 1;\n";
    s = s + "      if (i == 0) break;\n";
    s = s + "   }\n";
    s = s + "   return null;\n";
    s = s + "}\n";
    s = s + "\n";
    s = s + "// End -->\n";
    s = s + "</script>\n";
    return s;
  }

  public void doGet(HttpServletRequest httpservletrequest, 
                    HttpServletResponse httpservletresponse) throws ServletException, 
                                                                    IOException
  {
    httpservletresponse.setContentType("text/html");
    PrintWriter printwriter = httpservletresponse.getWriter();
    HttpSession httpsession = httpservletrequest.getSession(false);
    if (httpsession != null && httpsession.getAttribute("usuario") != null)
      usuario = httpsession.getAttribute("usuario").toString();
    if (usuario == null)
      usuario = "";
    if (usuario.length() == 0)
      printwriter.println("Error, usuario no valido");
    String s = 
      generaPagoLinea(httpservletrequest, httpservletresponse, usuario);
    printwriter.println(s);
  }

  public void doPost(HttpServletRequest httpservletrequest, 
                     HttpServletResponse httpservletresponse) throws IOException, 
                                                                     ServletException
  {
    doGet(httpservletrequest, httpservletresponse);
  }

  public static void generaAmbiente(HttpServletRequest httpservletrequest) throws IOException
  {
    String s = "mocte";
    String s1 = "/kaizen/" + s + "Web.properties";
    Properties properties = utilerias.loadProperties(s1);
    dirPlantillasGenerales = properties.getProperty("plantillas");
    datColorRen = "";
    datFont = properties.getProperty("datFont");
    datTamFont = properties.getProperty("datTamFont");
    datColorFont = properties.getProperty("datColorFont");
  }

  public static String generaPagoLinea(HttpServletRequest httpservletrequest, 
                                       HttpServletResponse httpservletresponse, 
                                       String s) throws IOException
  {
    HttpSession httpsession = httpservletrequest.getSession(false);
    String s1 = "";
    String s4 = "";
    String s7 = "";
    String s10 = "";
    String s11 = "";
    String s14 = "";
    String s15 = "";
    String s16 = "";
    String s17 = "";
    String s19 = "";
    String s21 = "";
    String s23 = "";
    generaAmbiente(httpservletrequest);
    String s24 = "";
    String s26 = 
      utilerias.validaNulo(httpservletrequest.getParameter("edo_pago"));
    if (s26.equals("") || s26.equals("null"))
    {
      String s25 = genera_clientes(s, "");
      String s12 = templates.generaHidden("edo_pago", "0");
      String s2 = 
        utilerias.replaceString1(templates.generaTexto("txtSub", "20", "20", 
                                                       "0.00"), ">", 
                                 " disabled>");
      String s5 = 
        utilerias.replaceString1(templates.generaTexto("txtAnti", "20", "20", 
                                                       "0.00"), ">", 
                                 " disabled>");
      String s8 = 
        utilerias.replaceString1(templates.generaTexto("txtTot", "12", "20", 
                                                       "0.00"), ">", 
                                 " disabled>");
      s10 = 
          utilerias.replaceString1(templates.generaTextArea("comentario", "1000", 
                                                            "60", "5", s10), 
                                   ">", " disabled>");
      String s27 = templates.getHost();
      String s29 = dirPlantillasGenerales + plant_pago;
      String s31 = "<SCRIPT LANGUAGE=\"JavaScript\">\n";
      s31 = s31 + "<!-- Begin\n";
      s31 = s31 + "function createCookie(name,value,days)\n";
      s31 = s31 + "{\n";
      s31 = s31 + "   if (days)\n";
      s31 = s31 + "   {\n";
      s31 = s31 + "      var date = new Date();\n";
      s31 = s31 + "      date.setTime(date.getTime()+(days*24*60*60*1000));\n";
      s31 = s31 + "      var expires = \"; expires=\"+date.toGMTString();\n";
      s31 = s31 + "   }\n";
      s31 = s31 + "   else var expires = \"\";\n";
      s31 = s31 + "   document.cookie = name+\"=\"+value+expires+\";\";\n";
      s31 = s31 + "}\n";
      s31 = s31 + "// End -->\n";
      s31 = s31 + "</SCRIPT>\n";
      s23 = templates.generaPlantilla(s29, s27);
      s23 = utilerias.replaceString1(s23, "--script--", s31);
      s23 = 
          utilerias.replaceString1(s23, "--clientes--", utilerias.replaceString1(s25, 
                                                                                 "onChange=\"submit()\"", 
                                                                                 "onChange=\"createCookie('namepago','" + 
                                                                                 s + 
                                                                                 "', 1);submit()\""));
      s23 = utilerias.replaceString1(s23, "--tabla_grid--", "");
      s23 = utilerias.replaceString1(s23, "--txtSub--", s2);
      s23 = utilerias.replaceString1(s23, "--txtAnti--", s5);
      s23 = utilerias.replaceString1(s23, "--txtTot--", s8);
      s23 = utilerias.replaceString1(s23, "--txtCom--", s10);
      s23 = utilerias.replaceString1(s23, "--hidden--", s12);
      s23 = utilerias.replaceString1(s23, "--folio--", folio);
      s23 = utilerias.replaceString1(s23, "--comprobante--", "");
      s23 = 
          utilerias.replaceString1(s23, "value=\"Procesar\">", "value=\"Procesar\" disabled>");
    } else
    {
      if (s26.equals("0"))
      {
        String s28 = httpservletrequest.getParameter("cliente");
        String s18 = 
          " SELECT 1,'FACT',                                         FACT_SERIE||'-'||TO_CHAR(FACT_NUMERO),            FACT_SUBTOTAL_FACTURA + FACT_MONTO_IVA,           FACT_SALDO_SUBTOTAL + FACT_SALDO_IVA - SCC_F_APLICA_ACLARA_INT_DOCTO('FACT', FACT_SERIE, FACT_NUMERO, NULL)       FROM   SCC_FACTURAS                               WHERE  FACT_CLNT_NUMERO                     =    " + 
          s28 + " AND    FACT_STATUS       IN ('I','L','P','R')    " + 
          " AND    FACT_SALDO_SUBTOTAL + FACT_SALDO_IVA - SCC_F_APLICA_ACLARA_INT_DOCTO('FACT', FACT_SERIE, FACT_NUMERO, NULL) != 0 " + 
          " UNION                                             " + 
          " SELECT 2,'NOCA', " + 
          "        NOCA_SERIE||'-'||TO_CHAR(NOCA_NUMERO),    " + 
          "        NOCA_SUBTOTAL_NOTA + NOCA_MONTO_IVA,      " + 
          "        NOCA_SALDO_SUBTOTAL + NOCA_SALDO_IVA - SCC_F_APLICA_ACLARA_INT_DOCTO('NOCA', NOCA_SERIE, NOCA_NUMERO, NOCA_TIPO_NOTA)      " + 
          " FROM   SCC_NOTAS_CARGO                           " + 
          " WHERE  NOCA_CLNT_NUMERO                     =    " + s28 + 
          " AND    NOCA_STATUS        IN ('I','L','P','R')   " + 
          " AND    NOCA_SALDO_SUBTOTAL + NOCA_SALDO_IVA - SCC_F_APLICA_ACLARA_INT_DOCTO('NOCA', NOCA_SERIE, NOCA_NUMERO, NOCA_TIPO_NOTA) != 0 " + 
          " AND    NOCA_TIPO_NOTA                       = 'N'" + 
          " UNION                                            " + 
          " SELECT 3,'AVCA', " + 
          "        NOCA_SERIE||'-'||TO_CHAR(NOCA_NUMERO),    " + 
          "        NOCA_SUBTOTAL_NOTA + NOCA_MONTO_IVA,      " + 
          "        NOCA_SALDO_SUBTOTAL + NOCA_SALDO_IVA - SCC_F_APLICA_ACLARA_INT_DOCTO('AVCA', NOCA_SERIE, NOCA_NUMERO, NOCA_TIPO_NOTA)      " + 
          " FROM   SCC_NOTAS_CARGO                           " + 
          " WHERE  NOCA_CLNT_NUMERO                     =    " + s28 + 
          " AND    NOCA_STATUS        IN ('I','L','P','R')   " + 
          " AND    NOCA_SALDO_SUBTOTAL + NOCA_SALDO_IVA - SCC_F_APLICA_ACLARA_INT_DOCTO('AVCA', NOCA_SERIE, NOCA_NUMERO, NOCA_TIPO_NOTA) != 0 " + 
          " AND    NOCA_TIPO_NOTA                       = 'A'" + 
          " AND    NOT         EXISTS (SELECT 'X'            " + 
          "                            FROM   SCC_NOTAS_CARGO_FACTURA                           " + 
          "                            WHERE  NOFA_NOCA_SERIE     = NOCA_SERIE                  " + 
          "                            AND    NOFA_NOCA_NUMERO    = NOCA_NUMERO                 " + 
          "                            AND    NOFA_NOCA_TIPO_NOTA = NOCA_TIPO_NOTA              " + 
          "                            AND    NOFA_AFECTA_SUB     = 'N'                         " + 
          "                            UNION                                                    " + 
          "                            SELECT 'X'                                               " + 
          "                            FROM   SCC_NOTAS_CARGO_CREDITO, SCC_NOTAS_CREDITO_FACTURA" + 
          "                            WHERE  NCCR_NOCA_SERIE     = NOCA_SERIE                  " + 
          "                            AND    NCCR_NOCA_NUMERO    = NOCA_NUMERO                 " + 
          "                            AND    NCCR_NOCA_TIPO_NOTA = NOCA_TIPO_NOTA              " + 
          "                            AND    NOCF_NOCR_SERIE     = NCCR_NOCR_SERIE             " + 
          "                            AND    NOCF_NOCR_NUMERO    = NCCR_NOCR_NUMERO            " + 
          "                            AND    NOCF_NOCR_TIPO_NOTA = NCCR_NOCR_TIPO_NOTA         " + 
          "                            AND    NOCF_AFECTA_SUB     = 'N')                        " + 
          " UNION                                            " + 
          " SELECT 4,'PAGA',                                 " + 
          "        PAGA_SERIE||'-'||TO_CHAR(PAGA_NUMERO),    " + 
          "        PAGA_SUBTOTAL_PAGARE + PAGA_MONTO_IVA,    " + 
          "        PAGA_SALDO_SUBTOTAL + PAGA_SALDO_IVA - SCC_F_APLICA_ACLARA_INT_DOCTO('PAGA', PAGA_SERIE, PAGA_NUMERO, null)      " + 
          " FROM   SCC_PAGARES                               " + 
          " WHERE  PAGA_CLNT_NUMERO                     =    " + s28 + 
          " AND    PAGA_STATUS        IN ('I','L','P','R')   " + 
          " AND    PAGA_SALDO_SUBTOTAL + PAGA_SALDO_IVA - SCC_F_APLICA_ACLARA_INT_DOCTO('PAGA', PAGA_SERIE, PAGA_NUMERO, null) != 0 " + 
          " ORDER BY 1";
        Vector vector = DbAppUnivC.execQuery(s18);
        String s32 = "";
        String s34 = "";
        String s38 = "";
        String s40 = "";
        boolean flag = false;
        double d = 0.0D;
        double d1 = 0.0D;
        httpsession.setAttribute("NumFact", Integer.toString(vector.size()));
        if (vector != null && vector.size() > 0)
        {
          for (int k = 0; k < vector.size(); k++)
          {
            dbRecord dbrecord = (dbRecord)vector.elementAt(k);
            String s33 = 
              templates.generaTexto("tpoDocto" + k, "10", "10", dbrecord.getField(2));
            String s35 = 
              templates.generaTexto("docto" + k, "10", "10", dbrecord.getField(3));
            String s39 = 
              templates.generaTexto("monto" + k, "10", "10", utilerias.redondea(dbrecord.getField(4)));
            d += Double.valueOf(dbrecord.getField(4)).doubleValue();
            String s41 = 
              templates.generaTexto("saldo" + k, "10", "10", utilerias.redondea(dbrecord.getField(5)));
            d1 += Double.valueOf(dbrecord.getField(5)).doubleValue();
            String s20 = templates.generaCheck("pago", "0");
            String s22 = 
              templates.generaTexto("totPago" + k, "20", "20", "0.00");
            String s52 = utilerias.replaceString1(s33, ">", " readonly>");
            String s54 = utilerias.replaceString1(s35, ">", " readonly>");
            String s56 = utilerias.replaceString1(s39, ">", " readonly>");
            String s58 = utilerias.replaceString1(s41, ">", " readonly>");
            s20 = 
                utilerias.replaceString1(s20, ">", " onclick=\"actualiza_saldo(" + 
                                         k + ")\">");
            String s59 = 
              utilerias.replaceString1(s22, ">", " Onblur='total(" + k + 
                                       ")' disabled>");
            s16 = s16 + "<tr align=\"center\">";
            s16 = 
                s16 + templates.tablaCol(s52, datColorFont, datFont, datTamFont, 
                                         datColorRen);
            s16 = 
                s16 + templates.tablaCol(s54, datColorFont, datFont, datTamFont, 
                                         datColorRen);
            s16 = 
                s16 + templates.tablaCol(s56, datColorFont, datFont, datTamFont, 
                                         datColorRen);
            s16 = 
                s16 + templates.tablaCol(s58, datColorFont, datFont, datTamFont, 
                                         datColorRen);
            s16 = 
                s16 + templates.tablaCol(s20, datColorFont, datFont, datTamFont, 
                                         datColorRen);
            s16 = 
                s16 + templates.tablaCol(s59, datColorFont, datFont, datTamFont, 
                                         datColorRen);
            s16 = s16 + "</tr>";
          }

        }
        s16 = s16 + "<tr align=\"center\">";
        s16 = 
            s16 + templates.tablaCol("Totales", datColorFont, datFont, datTamFont, 
                                     datColorRen);
        s16 = 
            s16 + templates.tablaCol("", datColorFont, datFont, datTamFont, datColorRen);
        s16 = 
            s16 + templates.tablaCol(utilerias.redondea(Double.toString(d)), datColorFont, 
                                     datFont, datTamFont, datColorRen);
        s16 = 
            s16 + templates.tablaCol(utilerias.redondea(Double.toString(d1)), datColorFont, 
                                     datFont, datTamFont, datColorRen);
        s16 = 
            s16 + templates.tablaCol("", datColorFont, datFont, datTamFont, datColorRen);
        s16 = 
            s16 + templates.tablaCol("", datColorFont, datFont, datTamFont, datColorRen);
        s16 = s16 + "</tr>";
        String s3 = templates.generaTexto("txtSub", "20", "20", "0.00");
        String s6 = templates.generaTexto("txtAnti", "20", "20", "0.00");
        String s9 = templates.generaTexto("txtTot", "12", "20", "0.00");
        s10 = templates.generaTextArea("comentario", "1000", "60", "5", s10);
        s10 = 
            utilerias.replaceString1(s10, ">", " onChange=\"javascript:this.value=this.value.toUpperCase();\">");
        String s49 = utilerias.replaceString1(s3, ">", " readonly>");
        String s51 = 
          utilerias.replaceString1(s6, ">", " Onblur='totalgen()'>");
        s9 = utilerias.replaceString1(s9, ">", "  readonly>");
        String s13 = templates.generaHidden("edo_pago", "0");
        String s53 = templates.getHost();
        String s55 = dirPlantillasGenerales + plant_pago;
        String s57 = Genera_JavaScript();
        s23 = templates.generaPlantilla(s55, s53);
        s23 = utilerias.replaceString1(s23, "--script--", s57);
        s23 = 
            utilerias.replaceString1(s23, "--clientes--", genera_clientes(s, s28));
        s23 = utilerias.replaceString1(s23, "--tabla_grid--", s16);
        s23 = utilerias.replaceString1(s23, "--txtSub--", s49);
        s23 = utilerias.replaceString1(s23, "--txtAnti--", s51);
        s23 = utilerias.replaceString1(s23, "--txtTot--", s9);
        s23 = utilerias.replaceString1(s23, "--txtCom--", s10);
        s23 = utilerias.replaceString1(s23, "--folio--", folio);
        s23 = utilerias.replaceString1(s23, "--comprobante--", "");
        s23 = utilerias.replaceString1(s23, "--hidden--", s13);
      }
      if (s26.equals("1"))
      {
        int i = Integer.parseInt(httpsession.getAttribute("NumFact").toString());
        String s30 = httpservletrequest.getParameter("cliente") + ",|";
        for (int j = 0; j < i; j++)
        {
          String s36 = 
            httpservletrequest.getParameter("totPago" + Integer.toString(j));
          if (s36 != null && !s36.trim().equals(""))
            s30 = 
                s30 + httpservletrequest.getParameter("tpoDocto" + Integer.toString(j)) + 
                ";" + 
                httpservletrequest.getParameter("docto" + Integer.toString(j)) + 
                ";" + utilerias.replaceString(s36, ",", "") + "|";
        }

        String s37 = httpservletrequest.getParameter("txtAnti");
        float f = Float.parseFloat(utilerias.replaceString(s37, ",", ""));
        if (s37 != null && !s37.trim().equals("") && f > 0.0F)
          s30 = s30 + "ANTI;;" + utilerias.replaceString(s37, ",", "") + "|";
        s30 = 
            s30 + "," + utilerias.validaNulo(httpservletrequest.getParameter("comentario")) + 
            ",";
        ejecuta ejecuta1 = new ejecuta();
        String s42 = 
          ejecuta.store("SCC_P_INSERTA_PAGO_INTERNET(,N,V,V,V)", s30, 3, 1);
        String s43 = "";
        String s45 = "";
        String s47 = "";
        if (s42.indexOf("-") >= 0)
        {
          String s44 = s42.substring(0, s42.indexOf("-"));
          String s46 = s42.substring(s42.indexOf("-") + 1, s42.indexOf(";"));
          folio = "Folio Internet: " + s44 + "-" + s46;
          s47 = 
              "<input type='reset' name='btn_com' value='Comprobante'  OnClick = \"javascript:window.open('/servlet/pago?serie=" + 
              s44 + "&numero=" + s46 + 
              "','window','resizable,scrollbars=1,width=840,height=400,left = 80,top = 100');\">";
        } else
        {
          folio = 
              "\"" + s42 + "\" Existio un Error al Insertar en la BD. Consulte al Administrador";
          s47 = "";
        }
        String s48 = templates.getHost();
        String s50 = dirPlantillasGenerales + plant_pago_folio;
        s23 = templates.generaPlantilla(s50, s48);
        s23 = utilerias.replaceString1(s23, "--folio--", folio);
        s23 = utilerias.replaceString1(s23, "--comprobante--", s47);
      }
    }
    return s23;
  }

  public static String genera_clientes(String s, String s1)
  {
    String s2 = "";
    try
    {
      System.out.println("Usuario = " + s);
      String s3 = "SELECT uspe_norm_rest ";
      s3 = s3 + "FROM  scc_usuarios_perfil ";
      s3 = s3 + "WHERE uspe_clave = UPPER('" + s + "')";
      String s4 = utilerias.valorSqlUni(s3);
      System.out.println("Restringido = " + s4);
      String s5 = "";
      if (s4.equals("N"))
      {
        s5 = 
            "SELECT clnt_numero, clnt_numero ||' - '|| SUBSTR(clnt_razon_social,1,30) ";
        s5 = s5 + "FROM  scc_clientes ";
        s5 = s5 + "WHERE clnt_stcl_clave = 'ACTI' ";
        s5 = s5 + "ORDER BY clnt_numero";
      } else
      {
        s5 = 
            "SELECT clnt_numero, clnt_numero ||' - '|| SUBSTR(clnt_razon_social,1,30) ";
        s5 = s5 + "FROM  scc_clientes_usuario, scc_clientes ";
        s5 = s5 + "WHERE clus_uspe_clave = UPPER('" + s + "') ";
        s5 = s5 + "AND   clnt_numero     = clus_clnt_numero ";
        s5 = s5 + "AND   clnt_stcl_clave = 'ACTI' ";
        s5 = s5 + "ORDER BY 2";
      }
      s2 = templates.generaComboJump("cliente", s5, s1);
    } catch (Exception exception)
    {
      System.out.println("Error al generer los clientes; pago en linea: " + 
                         exception.toString());
    }
    return s2;
  }

  static String dirPlantillasGenerales = "";
  static String datColorRen = "";
  static String datFont = "";
  static String datTamFont = "";
  static String datColorFont = "";
  static String usuario = "";
  static String plant_pago = "pgral_ideograma/pagolinea.html";
  static String plant_pago_folio = "pgral_ideograma/pago_folio.html";
  static String plant_pago_confirma = "pgral_ideograma/pago.html";
  static String folio = " ";

}
